#pragma once
#include <sys/types.h>
#include <slack/std.h>
#include <slack/link.h>

struct command_t {
    dlink_t link;
    char *cmd;
    void (*function)(plugin*,int,char**);
    int min_args;
    int max_args;
};

typedef struct command_t command;

int command_add(plugin *p, const char *cmd, void (*function)(), int min_args, int max_args);
int command_remove(const char *cmd);
void commands_init(void);
command *cmd_to_command(const char *cmd);

void cmd_command_add(plugin *p, const char **argv);
void cmd_command_remove(plugin *p, const char **argv);
void cmd_command_exists(plugin *p, const char **argv);
void cmd_command_list(plugin *p);

extern command *commands;

void cmd_run2(plugin *p, char *buf);
void cmd_run(plugin *p, const char *buf);
void rmnl(char *buf);
void argv_free(char **argv);
char **argv_split(const char *str, int *argcp);
void remote_cmd(char *plugin_name, char *cmd_name, const char **argv, int argc);
